/*
 * WeatherServer.cpp
 *
 *  Created on: Apr 13, 2010
 *      Author: songyp
 */

#include "WeatherServer.h"
#include "WeatherSession.h"

#include <e32debug.h>

_LIT(KPanicText, "WeatherServer");
_LIT(KServerName, "WeatherServer");

CWeatherServer::CWeatherServer() : CServer2( EPriorityStandard )
	{
	
	}

CWeatherServer::~CWeatherServer()
	{
	
	}

CWeatherServer * CWeatherServer::NewL()
	{
	CWeatherServer * self = new (ELeave) CWeatherServer;
	CleanupStack::PushL( self );
	self->ConstructL();
	CleanupStack::Pop();
	return self;
	}

void CWeatherServer::ConstructL()
	{
	
	}

CSession2 * CWeatherServer::NewSessionL( const TVersion &aVersion, 
		const RMessage2 &aMessage ) const
	{
	RDebug::Print( _L("CWeatherServer::NewSessionL") );
	return CWeatherSession::NewL();
	}



TInt E32Main()
	{
	CTrapCleanup *cleanup = CTrapCleanup::New();
	
	CActiveScheduler *scheduler = new CActiveScheduler;
	CActiveScheduler::Install( scheduler );
	
	CWeatherServer *server = NULL;
	TRAPD( err, server = CWeatherServer::NewL() );
	if( !KErrNone == err )
		{
		User::Panic( KPanicText, EGeneralPanic );
		}
	
	TRAP( err, server->StartL( KServerName ) );
	if( !KErrNone == err )
		{
		User::Panic( KPanicText, EGeneralPanic );
		}
	
	RProcess::Rendezvous( KErrNone );
	
	CActiveScheduler::Start();
	
	delete server;
	delete scheduler;
	delete cleanup;
	
	return KErrNone;
	}
